﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.XSchEmA.Entity;
using Pixysoft.Framework.XSchEmA.Sql;

namespace Pixysoft.Framework.XSchEmA
{
    /// <summary>
    /// 针对不同数据库的特殊方法
    /// </summary>
    internal interface ISchemaAspect
    {
        /// <summary>
        /// 获取对应的sqlbuilder
        /// </summary>
        ISqlBuilder SqlBuilder { get;}

        /// <summary>
        /// 手动建新字段使用
        /// </summary>
        /// <param name="column">The column.</param>
        DataTypeSchema GetDefaultDataType();

        /// <summary>
        /// 手动修改类型使用
        /// </summary>
        /// <param name="column">The column.</param>
        DataTypeSchema AutoCompleteDataType(string datatype);

        /// <summary>
        /// 手动修改数据类型使用.不考虑表结构
        /// 类型精度，是否存在等
        /// </summary>
        /// <param name="datatype">The datatype.</param>
        /// <param name="length">The length.</param>
        /// <param name="precision">The precision.</param>
        /// <param name="scale">The scale.</param>
        /// <returns>
        /// 	<c>true</c> if [is valid data type] [the specified datatype]; otherwise, <c>false</c>.
        /// </returns>
        bool IsValidDataType(DataTypeSchema datatype);

        /// <summary>
        /// 显示提示、修改数据类型使用
        /// </summary>
        /// <param name="datatype">The datatype.</param>
        /// <returns>
        /// 	<c>true</c> if [is unique data type] [the specified datatype]; otherwise, <c>false</c>.
        /// </returns>
        bool IsUniqueDataType(DataTypeSchema datatype);

        /// <summary>
        /// 取得c#类型字段，用户生成DataTable
        /// </summary>
        /// <param name="column">The column.</param>
        /// <returns></returns>
        string GetDotNetDataType(DataTypeSchema datatypeSchema);

        /// <summary>
        /// 获得c#类型的字段类型，用于不同数据库转换
        /// </summary>
        /// <param name="datatypeSchemas">The datatype schemas.</param>
        /// <returns></returns>
        void TransformToGeneral(DatabaseSchema schema);

        /// <summary>
        /// 任意数据库转换成为本类型,入口数据库必须是通用型数据库
        /// </summary>
        /// <param name="database">The database.</param>
        void Transformation(DatabaseSchema database);



        /// <summary>
        /// 取得类型列表
        /// </summary>
        /// <returns></returns>
        List<string> GetDataTypeList();

        /// <summary>
        /// Gets the data type regex list.
        /// </summary>
        /// <returns></returns>
        List<string> GetDataTypeRegexList();

        List<string> GetKeyWordsList();


        /// <summary>
        /// 命名是否合法
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns>
        /// 	<c>true</c> if [is valid name] [the specified name]; otherwise, <c>false</c>.
        /// </returns>
        bool IsValidName(string name);

        /// <summary>
        /// 查看字段默认值是否正确
        /// </summary>
        /// <param name="input"></param>
        /// <param name="datatype"></param>
        /// <returns></returns>
        string ValidateDefaultValue(string input, DataTypeSchema datatype);



        /// <summary>
        /// 创建一个数据库
        /// </summary>
        /// <param name="command"></param>
        /// <param name="databasename"></param>
        void CreateDatabase(ISchemaCommand command, string databasename);

        /// <summary>
        /// 删除一个数据库
        /// </summary>
        /// <param name="command"></param>
        /// <param name="databasename"></param>
        void DropDatabase(ISchemaCommand command, string databasename);


    }
}
